1
2 #include<stdio.h>
3 #include<stdlib.h>
4 #include<conio.h>
5 #include<string.h>
6 #include<windows.h>
7 #include<time.h>
8
9
10 ///Logic Functions
11
12 /// Update & Insert Function
13 void insertfirst(int data, char foodname[25], int quantity, float price);
14 void insertmid(int pos, int data, char foodname[25], int quantity, float price);
15 void insertend(int data, char foodname[25], int quantity, float price);
16 void updatefood(int udata, int uquantity);
17
18 /// Display Function
19 void foodlist();
20 void order_view(int order, int quantity, int or_no);
21 void main_menu();
22
23 ///Delete & Count Function
24 void deletefood(int serial);
25 int countitem();
26
27
28
29
30 ///extra design Function
31
32 void cls();
33 void echo(char print[]);
34 void br(int line);
35 void pre(int tab);
36 void span(int space);
37 void ccolor(int clr);
38 void pwellcome();
39 void loadingbar();
40 void middle1(void);
41 void middtab1(void);
42 void backuploader(void);
43
44
45 ///START Structure Here
46
47 struct Node{
48
49 char foodname[50];
50 int quantity;
51 float price;
52 int data;
53 struct Node *next;
54
55 };
56
57 ///Global Type
58
59 typedef struct Node node ;
60
61 node *head, *list;
62
63 int main(){
64
65 system("title Fruit House System");
66 system("mode con: cols=88 lines=30");
67
68
69 loadingbar(); cls();
70 pwellcome();
71 Sleep(300);
72 cls();
73
74 int c=0; int any;
75 int cardno[100];
76 float cardmoney[100];
77 float totalmoney = 0;
78 int total_order[100];
79 int order_quantity[100];
80 int order=0;
81 int uquantity;
82 int citem;
83
84 head = NULL;
85 insertfirst(5,"Season Fruits",23,120.23);
86 insertfirst(4,"Jack Fruits",50,300);
87 insertfirst(3,"Fruit Salad",100, 150);
88 insertfirst(2,"Fruit Juice",23,220);
89
90
91
92 mainmenu:
93 br(1);
94
95 main_menu();
96
97 int main_menu_choice;
98
99 br(1); pre(4); fflush(stdin); scanf("%d",&main_menu_choice);
100
101 if((main_menu_choice >=1 && main_menu_choice <=3)){
102
103 if(main_menu_choice == 1){
104
105 foodlist:
106
107 cls();
108 printf("=> 0. Main Menu ");
109 foodlist();
110
111
112 }
113
114 else if( main_menu_choice == 2){
115
116 adminpanelchoice:
117
118 int admin_panel_choice;
119
120 cls(); middle1() ; pre(4); printf("1. Main Menu\n\n\t"); Sleep(300);
121 printf("Please Enter Password or ( 1 to Back in Main Menu ) : ");
122
123
124 fflush(stdin); scanf("%d",&admin_panel_choice);
125
126 if(admin_panel_choice==12345678){
127
128
129
130 node *temp;
131
132 temp = list;
133
134 adminchoise:
135
136 cls(); br(3); pre(4); echo(">>>> Admin Dashboard <<<< \n\n");
137 pre(4);
138 printf(" 1. Total Cash Today \n\n");Sleep(250);pre(4);
139 printf(" 2. View Card Pay \n\n");Sleep(250);pre(4);
140 printf(" 3. Add Fruits in Stock \n\n");Sleep(250);pre(4);
141 printf(" 4. Delete Fruits from Stock \n\n");Sleep(250);pre(4);
142 printf(" 5. Instant Fruit Stock List \n\n");Sleep(250);pre(4);
143 printf(" 6. Item Counter \n\n");Sleep(250);pre(4);
144 printf(" 7. Backup System\n\n");Sleep(250);pre(4);
145 printf(" 8. Instant Order Preview\n\n");Sleep(250);pre(4);
146 printf(" 0. Main Menu \n\n");
147 printf("Enter Your From 1-0: ");
148 Sleep(250);
149
150 int adminchoise;
151
152
153
154 fflush(stdin); scanf("%d",&adminchoise);
155
156 if(adminchoise==1){
157
158 cls(); middle1(); pre(4); printf("Todays Total Cash : %0.2f \n",totalmoney);
159
160 Sleep(2000);
161
162 goto adminchoise;
163 }
164 else if(adminchoise==2){
165
166 if(c!=0){
167
168 cls(); br(3); pre(4);
169
170 printf(" ____________________________\n");pre(4);
171 printf("| Card NO. | Money $ |\n");pre(4);
172 printf("------------------------------\n");pre(4);
173
174 for(int z=1; z<=c;z++){
175
176 printf("| %d | %0.2f |\n",cardno[z],cardmoney[z]);pre(4);
177 printf("------------------------------\n");pre(4);
178 Sleep(150);
179
180 }
181 Sleep(1500);
182 }
183
184 if(c==0){
185
186 cls(); middle1(); pre(4);
187 printf("No Card History\n");}
188 Sleep(1500);
189 goto adminchoise;
190 }
191
192 else if(adminchoise==3){
193
194 foodadd:
195 cls();
196
197 char ffoodname[25];
198 int fquantity;
199 int fdata;
200 float fprice;
201 int fposi;
202
203
204 br(3);pre(4); printf(" Enter Type of Fruit Name : ");
205
206 fflush(stdin); scanf("%[^\n]s",ffoodname);
207 fquantity:
208 fflush(stdin);
209
210 br(2);pre(4);
211 printf(" Enter Item Quantity : ");
212
213 scanf("%d",&fquantity); fflush(stdin);
214
215 foodserial:
216 br(2);pre(4); printf(" Enter Fruit Serial : ");
217 scanf("%d",&fdata);
218 node *exist;
219 exist = list;
220 while(exist->data!=fdata){
221 if(exist->next==NULL){
222 break;
223 }
224 exist=exist->next;
225 }
226 if(exist->data==fdata){
227 cls(); br(5);pre(3); printf(" Item Serial Already Exist, Please Re-Enter "); Sleep(2000);
228 goto foodserial;
229 }
230
231 fprice:
232 fflush(stdin);
233
234 br(2);pre(4); printf(" Enter Item Price : ");fflush(stdin);
235
236 scanf("%f",&fprice);
237
238
239
240 br(2);pre(4); printf("Submitting your data");for(int cs=0;cs<4;cs++){printf(" .");Sleep(500);}
241
242
243 insertend(fdata,ffoodname,fquantity,fprice);
244
245 br(2);pre(4); printf("Adding Item Successfull.......\n");
246
247 Sleep(2000);
248
249 goto adminchoise;
250
251 }
252 else if(adminchoise==4){
253
254 cls();
255 middle1();pre(2);
256 printf("Enter Serial No of the Item To Delete : ");
257 fdelete:
258 int fdelete;
259 fflush(stdin); scanf("%d",&fdelete);
260 node *temp;
261 temp=list;
262 while(temp->data != fdelete){
263 temp = temp->next;
264 }
265 if(temp->data==fdelete){
266 deletefood(fdelete);
267 }
268 else{
269 br(2); pre(2); printf("Please Enter Correct Number : "); Sleep(500);
270 goto fdelete;
271 }
272
273
274 goto adminchoise;
275 }
276
277 else if(adminchoise==5){
278
279 cls(); foodlist(); Sleep(1000);
280
281 br(2);pre(4); printf("1. <-- back \n\n");pre(5);
282
283
284
285 fflush(stdin); scanf("%d",&any);
286
287 goto adminchoise;
288
289 }
290
291 else if(adminchoise==6){
292
293 citem = countitem();
294 cls();
295 for(int cs=1;cs<=citem;cs++){
296 middle1(); pre(4);
297 printf("Item Counting ");
298 printf(" %d ",cs);
299 Sleep(150);
300 cls();
301 }
302 cls();
303 middle1();pre(4);
304 printf("Total Item Item is --> %d \n",citem); Sleep(2000);
305 goto adminchoise;
306
307 }
308
309 ///Backup System
310 else if(adminchoise==7){
311
312
313 char date[35]=__DATE__;
314
315 strcat(date,".txt");
316 FILE *fptr;
317 fptr=fopen(date,"w");
318 backuploader();
319 if(fptr==NULL){
320 br(3); pre(3); printf("Error!"); Sleep(500);
321 goto adminchoise;
322 }
323 fprintf(fptr,"Total Cash Today : %0.2f\n\n\n",totalmoney);
324 fprintf(fptr,"Card No ------- Money \n\n");
325 for(int l=1; l<=c;l++){
326 fprintf(fptr,"%d ------- %0.2f \n",cardno[l],cardmoney[l]);
327 }
328 br(2);pre(4); printf("Backup Successfull..."); Sleep(1500);
329
330
331
332 fclose(fptr);
333 goto adminchoise;
334 }
335 else if(adminchoise==8){
336
337 cls();br(2);pre(2);
338 ccolor(26);
339 printf("\n\t\t"); ccolor(240);
340 printf("______________________________________________________ "); ccolor(26);
341 printf("\n\t\t"); ccolor(240);
342 printf("| Order No. | Item Name | Quantity | In Stock |"); ccolor(26);
343 printf("\n\t\t"); ccolor(240);
344 printf("------------------------------------------------------"); ccolor(26);
345 for(int o=1;o<=order;o++){
346 order_view(total_order[o],order_quantity[o],o);
347 }
348
349 br(2);pre(4); printf("1. <-- back \n\n");pre(5);
350
351 fflush(stdin); scanf("%d",&any);
352
353 goto adminchoise;
354
355
356
357 }
358 else if(adminchoise==0){
359
360 goto mainmenu;
361 }
362
363 else{
364 br(2); pre(4); printf("Please Select From List : "); Sleep(500);
365 goto adminchoise;
366 }
367
368
369
370 }
371
372 else if(admin_panel_choice==1){
373 goto mainmenu;
374 }
375 else{
376 br(2); pre(4); printf("Please Enter Correct Choice");
377 goto adminpanelchoice;
378 }
379
380 }
381
382 else if(main_menu_choice==3){
383 cls();
384 middle1(); pre(3); printf("Thank You For Using Our System. \n\t\t\tBrought To You By code-projects.org \n\n\n\n\n\n\n");
385 Sleep(1000);
386
387 exit(1);
388
389 }
390
391 }
392 else{
393 br(2); pre(4); printf("Please Enter Correct Choice"); Sleep(300);
394 goto mainmenu;
395 }
396
397
398 int get_food_choice;
399
400
401 br(2); pre(3);fflush(stdin);
402 printf("Place Your Order: ") ;
403 scanf("%d",&get_food_choice);
404
405 if(get_food_choice==0){
406 goto mainmenu;
407 }
408
409 node *temp;
410
411 temp = list ;
412
413 while(temp->data != get_food_choice){
414
415 temp = temp->next;
416 if(temp==NULL){
417 br(2); pre(4); echo("Please Choice From List: "); br(2); Sleep(1000);
418 goto foodlist;
419 }
420
421 }
422 if(get_food_choice == temp->data){
423
424 fcquantity:
425 br(2); pre(4);
426 printf("Enter Item Quantity : ");
427
428 int fcquantity;
429
430 fflush(stdin); scanf("%d",&fcquantity); cls();
431
432
433
434 if(fcquantity==0){
435 cls(); middle1();pre(3); printf("Quantity Can not be Zero "); Sleep(2000);
436 cls();
437 goto foodlist;
438 }
439 else if(fcquantity>temp->quantity){
440 cls(); middle1();pre(3); printf("Out of Stock ! "); Sleep(2000);
441
442 goto foodlist;
443 }
444
445 middle1();pre(4); printf("Choice item %s its price is %0.2f \n\n",temp->foodname,temp->price*fcquantity);pre(4);
446 printf("1. Confirm to buy this \n\n");pre(4);
447 printf("2. Item List \n\n");
448 printf("Press 1 to confirm and 2 to back to list :");
449
450 confirm:
451 int confirm;
452
453 fflush(stdin); scanf("%d",&confirm);
454
455 if(confirm == 1 ){
456
457 br(2);pre(4);
458 printf(" 1. Cash ");
459 br(2);pre(4);
460 printf(" 2. Credit\n");
461 printf("Select Method Of payment 1-2: ");
462 payment:
463 int payment;
464
465 fflush(stdin); scanf("%d",&payment);
466
467 if(payment==1){
468
469
470 totalmoney += temp->price*fcquantity;
471 order++;
472 total_order[order]=get_food_choice;
473 order_quantity[order]=fcquantity;
474 uquantity = temp->quantity - fcquantity;
475
476 updatefood(get_food_choice,uquantity);
477
478
479 cls();middle1();pre(4); printf("===>THANK YOU<===");
480 br(2);pre(4); printf("Item Ordered Successfully ...");
481 br(2);pre(4); printf("1. Wanna Buy Another ? ");
482 br(2);pre(4); printf("2. Main Menu \n");
483 br(2);pre(4); printf("Select: ");
484 psmenu:
485 int ps_menu;
486
487 fflush(stdin); scanf("%d",&ps_menu);
488
489 if(ps_menu==1){goto foodlist;}
490 else if(ps_menu==2){goto mainmenu;}
491 else{br(2);pre(4);printf("Please Choice from list : "); goto psmenu;}
492
493 }
494
495 ///Credit Card Option
496
497 else if(payment==2){
498
499 int card_number[100];
500
501 c++;
502
503 cls();middle1();pre(4); printf("Enter Your Card No : ");
504
505 fflush(stdin); scanf("%d",&card_number[c]);
506
507
508
509 cardno[c] = card_number[c];
510
511 int pin;
512
513 br(2);pre(2); printf("Enter Your Card Pin [we never save your pin] : ");
514
515 fflush(stdin); scanf("%d",&pin);
516
517 cardmoney[c] = temp->price*fcquantity;
518
519 totalmoney += temp->price*fcquantity;
520 order++;
521 total_order[order]=get_food_choice;
522 order_quantity[order]=fcquantity;
523
524 uquantity = temp->quantity - fcquantity;
525
526 updatefood(get_food_choice,uquantity);
527
528 br(2);pre(4); printf("Payment Success...");
529 br(2);pre(4); printf("1. Wanna Buy Another? ");
530 br(2);pre(4); printf("2. Main Menu \n");
531 br(2);pre(4); printf("select: ");
532 psmenu2:
533 int ps_menu2;
534
535 scanf("%d",&ps_menu2);
536
537 if(ps_menu2==1){goto foodlist;}
538 else if(ps_menu2==2){goto mainmenu;}
539 else{br(2);pre(4);printf("Please Choice from list : "); goto psmenu2;}
540
541 }
542
543 else{
544
545 br(2);pre(4); printf("Enter Choice from List : ");
546
547 goto payment;
548
549
550 }
551
552
553 } ///END Confirm Y/y
554
555
556
557 else if(confirm == 2){
558
559 goto foodlist;
560
561 }
562
563 else{
564 br(2);pre(4); printf("Enter Choice from List : ");
565
566 goto confirm;
567
568
569 } ///end confirm;
570
571
572 } ///end get food choice if line
573
574
575 else{
576
577 br(2);pre(4); echo("Please Choose From List "); br(2); Sleep(300);
578
579 goto foodlist;
580
581 } ///end get food choice
582 }
583
584 void cls(){
585
586 system("cls");
587
588 }
589
590 void echo(char print[]){
591
592 printf("%s",print);
593 }
594
595 void br(int line){
596 for(int i=0; i<line;i++){
597 printf("\n");
598 }
599 }
600
601 void pre(int tab){
602
603 for(int i=0; i<tab;i++){
604 printf("\t");
605 }
606
607 }
608 void span(int space){
609
610 for(int i=0; i<space;i++){
611 printf(" ");
612 }
613
614 }
615
616 void main_menu(){
617
618 cls();
619 br(5); pre(3); echo(">> 1. View List"); Sleep(400);
620 br(2); pre(3); echo(">> 2. Admin Dashboard"); Sleep(400);
621 br(2); pre(3); echo(">> 3. Exit"); Sleep(400);
622 // br(2); pre(3); echo("=> 4. Admin Panel"); Sleep(400);
623
624 br(1);
625
626 }
627
628 void insertend(int data, char foodname[25], int quantity, float price){
629
630 node *temp;
631
632 temp=(node *)malloc(sizeof(node));
633
634 temp->data = data;
635
636 temp->price = price;
637
638 temp-> quantity = quantity;
639
640 strcpy(temp->foodname,foodname);
641
642 temp->next = NULL;
643
644
645 if(head==NULL){
646 head = temp;
647 list = head;
648 }
649 else{
650
651 while(head->next != NULL){
652 head = head->next;
653 }
654
655 head->next = temp;
656 }
657
658 }
659
660 void insertfirst(int data, char foodname[25], int quantity, float price){
661
662 node *temp;
663
664 temp=(node *)malloc(sizeof(node));
665
666 temp->data = data ;
667
668 temp->price = price;
669
670 strcpy(temp->foodname,foodname);
671
672 temp-> quantity = quantity;
673
674
675 temp->next = head;
676
677 head = temp;
678
679 list = head ;
680
681 }
682
683 void insertmid(int pos, int data, char foodname[25], int quantity, float price){
684
685 node *temp;
686
687 temp=(node *)malloc(sizeof(node));
688
689 temp->data = data;
690
691 temp->price = price;
692
693 temp-> quantity = quantity;
694
695 strcpy(temp->foodname,foodname);
696
697 while(head->next->data != pos ){
698
699
700 head = head->next ;
701
702 }
703
704 temp->next = head->next;
705 head->next = temp ;
706
707 // free(temp);
708 }
709
710 void deletefood(int serial){
711
712 node *temp;
713 temp=(node *)malloc(sizeof(node));
714
715 temp = list;
716
717
718 if(temp->data != serial){
719
720 while(temp->next->data != serial){
721 temp = temp->next;
722 }
723
724 if(temp->next->data == serial){
725
726 temp->next = temp->next->next;
727 cls();
728 printf("\n\n\n\n\t\t\tDeleting Item %d ",serial);for(int cs=0;cs<4;cs++){printf(" .");Sleep(400);}
729
730 printf("\n\n\n\n\t\t\tDeleted Successfully \n"); Sleep(500);
731
732 }
733 else{
734 printf("\n\n\n\n\t\t\tCoffee Item Not Found\n"); Sleep(500);
735 }
736
737 head = temp ;
738
739 }
740 else{
741
742 temp = temp->next;
743 cls();
744 printf("\n\n\n\n\t\t\tDeleting Item %d ",serial);for(int cs=0;cs<4;cs++){printf(" .");Sleep(400);}
745
746 printf("\n\n\n\n\t\t\tDeleted Successfully \n"); Sleep(500);
747
748 head = temp ;
749
750 list=head;
751 }
752 }
753
754 void updatefood(int udata, int uquantity){
755
756 node *temp;
757 temp = list;
758
759 while(temp->data!=udata){
760 temp = temp->next;
761
762 }
763 if(temp->data == udata){
764 temp->quantity = uquantity;
765 }
766
767 }
768
769 int countitem(){
770
771 node *temp;
772
773 temp = list;
774
775 int countitem=0;
776
777 if(temp==NULL){
778 countitem = 0;
779 }
780 else{
781 countitem = 1;
782 while(temp->next != NULL){
783 countitem++;
784 temp = temp->next;
785 }
786
787 }
788
789
790 return countitem;
791
792 }
793 void foodlist(){
794
795 ccolor(0);
796
797 printf("\n\t\t"); ccolor(240);
798 printf("______________________________________________________ ");ccolor(26);
799 printf("\n\t\t"); ccolor(240);
800 printf("| Item No. | Item Name | Price | In Stock |");ccolor(26);
801 printf("\n\t\t"); ccolor(240);
802 printf("-------------------------------------------------------");ccolor(26);
803
804 node *temp;
805
806 temp = list;
807
808 while(temp != NULL){
809
810 ccolor(26);
811
812
813 printf("\n\t\t"); ccolor(62);
814 printf("| %d | %s | %0.2f | %d |",temp->data,temp->foodname, temp->price, temp->quantity);
815 ccolor(26);
816 printf("\n\t\t"); ccolor(62);
817 printf("-------------------------------------------------------");
818
819
820 temp = temp->next ;
821
822 Sleep(100);
823
824 }
825
826 ccolor(26);
827
828 // free(temp);
829
830 }
831
832
833 void order_view(int order, int quantity, int or_no){
834
835
836
837 ccolor(26);
838
839 node *temp;
840
841 temp = list;
842
843 while(temp->data != order){
844
845 temp = temp->next;
846
847 }
848 if(temp->data == order){
849
850 ccolor(26);
851
852 printf("\n\t\t"); ccolor(62);
853 printf("| %d | %s | %d | %d |",or_no,temp->foodname,quantity,temp->quantity);
854 ccolor(26);
855 printf("\n\t\t"); ccolor(62);
856 printf("-------------------------------------------------------");
857
858 Sleep(100);
859
860 }
861
862 ccolor(26);
863
864 }
865
866 void ccolor(int clr){
867
868 HANDLE hConsole;
869 hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
870 //SetConsoleTextAttribute(hConsole, clr);
871
872 //the above code displays colorful background. if you want colorful then you can remove the above comment but not the code, only comment//
873 }
874
875
876 ///HEERE PRINTF STYLE FUNCTION
877
878 void pwellcome(){
879 ccolor(26);
880
881 char welcome[50]="WELCOME";
882 char welcome2[50]=" TO";
883 char welcome3[50]=" SEASON";
884 char welcome4[50]=" FRUIT HOUSE";
885 printf("\n\n\n\n\n\t\t\t");
886 for(int wlc=0; wlc<strlen(welcome);wlc++){
887
888 printf(" %c",welcome[wlc]);
889 Sleep(100);
890 }
891 ccolor(26);
892 printf("\n\n\t\t\t\t ");
893 for(int wlc2=0; wlc2<strlen(welcome2) ;wlc2++){
894
895 printf(" %c",welcome2[wlc2]);
896 Sleep(100);
897 }
898 ccolor(26);
899 printf("\n\n\n\t\t\t ");
900 for(int wlc3=0; wlc3<strlen(welcome3) ;wlc3++){
901 if(welcome3[wlc3]!='D'){
902
903 printf(" %c",welcome3[wlc3]);
904 }
905 else{
906
907 printf(" %c",welcome3[wlc3]);
908 }
909
910 Sleep(100);
911 }
912 ccolor(26);
913 printf("\n\n\n\t\t\t\t ");
914 for(int wlc3=0; wlc3<strlen(welcome4) ;wlc3++){
915 if(welcome4[wlc3]!='A' && welcome4[wlc3]!='E'){
916
917 printf(" %c",welcome4[wlc3]);
918 }
919 else{
920
921 printf(" %c",welcome4[wlc3]);
922 }
923 Sleep(100);
924 }
925 ccolor(26);
926
927 }
928 void loadingbar(void){
929
930 for (int i=15;i<=100;i+=5){
931
932 cls();
933
934 printf("\n\n\n\n\n\n\n\t\t\t\t");
935 printf("%d %% Loading...\n\n\t\t",i);
936
937 printf("");
938
939 for (int j=0; j<i;j+=2){
940
941 ccolor(160+j);
942 printf(" ");
943 ccolor(26);
944
945 }
946 Sleep(100);
947 if(i==90 || i==50 || i==96 || i==83){
948 Sleep(100);
949 }
950
951 }
952
953 }
954 void backuploader(void){
955
956 for (int i=15;i<=100;i+=5){
957
958 cls();
959 ccolor(26);
960
961 printf("\n\n\n\n\n\n\n\t\t\t\t");
962 printf("%d %% Backing up the data keep patience...\n\n\t\t",i);
963
964 printf("");
965
966 for (int j=0; j<i;j+=2){
967
968 ccolor(120+j);
969 printf(" ");
970 ccolor(26);
971
972 }
973 Sleep(50);
974 if(i==90 || i==50 || i==96 || i==83){
975 Sleep(50);
976 }
977 }
978
979 }
980
981
982 void middle1(void){
983
984 printf("\n\n\n\n\n\n\n");
985 }
986
987 void middtab1(void){
988 printf("\t\t\t\t\t");
989 }